package com.openbravo.pos.payment;

import com.openbravo.pos.forms.AppConfig;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.util.AltEncrypter;

import java.awt.Dimension;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class ConfigPaymentPanelGeneric extends JPanel
  implements PaymentConfiguration
{
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JTextField jtxtCommerceID;
  private JPasswordField jtxtCommercePwd;

  public ConfigPaymentPanelGeneric()
  {
    initComponents();
  }

  public JPanel getComponent()
  {
    return this;
  }

  public void loadProperties(AppConfig paramAppConfig)
  {
    String str1 = paramAppConfig.getProperty("payment.commerceid");
    String str2 = paramAppConfig.getProperty("payment.commercepassword");
    if ((str1 != null) && (str2 != null) && (str2.startsWith("crypt:")))
    {
      this.jtxtCommerceID.setText(paramAppConfig.getProperty("payment.commerceid"));
      AltEncrypter localAltEncrypter = new AltEncrypter("cypherkey" + paramAppConfig.getProperty("payment.commerceid"));
      this.jtxtCommercePwd.setText(localAltEncrypter.decrypt(paramAppConfig.getProperty("payment.commercepassword").substring(6)));
    }
  }

  public void saveProperties(AppConfig paramAppConfig)
  {
    paramAppConfig.setProperty("payment.commerceid", this.jtxtCommerceID.getText());
    AltEncrypter localAltEncrypter = new AltEncrypter("cypherkey" + this.jtxtCommerceID.getText());
    paramAppConfig.setProperty("payment.commercepassword", "crypt:" + localAltEncrypter.encrypt(new String(this.jtxtCommercePwd.getPassword())));
  }

  private void initComponents()
  {
    this.jLabel1 = new JLabel();
    this.jtxtCommerceID = new JTextField();
    this.jLabel2 = new JLabel();
    this.jtxtCommercePwd = new JPasswordField();
    setPreferredSize(new Dimension(650, 75));
    this.jLabel1.setText(AppLocal.getIntString("label.commerceid"));
    this.jLabel2.setText(AppLocal.getIntString("label.commercepwd"));
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jLabel1).addComponent(this.jLabel2)).addGap(42, 42, 42).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(this.jtxtCommerceID, -2, 180, -2).addComponent(this.jtxtCommercePwd, -2, 180, -2)).addContainerGap(285, 32767)));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel1).addComponent(this.jtxtCommerceID, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jtxtCommercePwd, -2, -1, -2).addComponent(this.jLabel2)).addContainerGap(31, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.payment.ConfigPaymentPanelGeneric
 * JD-Core Version:    0.6.0
 */